package code19_jdk8.stream;

import java.util.Arrays;
import java.util.List;

public class Emp /*implements Comparable<Emp>*/ {
	public static enum State {// 状态
		FREE, // 空闲
		BUSY, // 忙碌
		VOCATION;// 休假
	}

	private String name;
	private Integer age;
	private Double sal;
	private State state;

	public Emp() {
	}

	public Emp(String name, Integer age, Double sal, State state) {
		super();
		this.name = name;
		this.age = age;
		this.sal = sal;
		this.state = state;
	}

	// 初始数据
	public static List<Emp> getData() {
		return Arrays.asList(
				new Emp("king", 28, 5000D, State.BUSY), 
				new Emp("jones", 20, 2975D, State.FREE), 
				new Emp("blake", 24, 2850D, State.VOCATION), 
				new Emp("clark", 27, 2450D, State.FREE),
				new Emp("scott", 22, 3000D, State.BUSY), 
				new Emp("ford", 26, 3000D, State.BUSY), 
				new Emp("allen", 30, 1600D, State.FREE),
				new Emp("ward", 32, 1250D, State.VOCATION), 
				new Emp("martin", 29, 1250D, State.FREE), 
				new Emp("turner", 26, 1500D, State.FREE),
				new Emp("james", 28, 950D, State.VOCATION), 
				new Emp("miller", 33, 1300D, State.FREE), 
				new Emp("adams", 35, 1100D, State.BUSY), 
				new Emp("smith", 21, 800D, State.BUSY),
				new Emp("smith", 21, 800D, State.BUSY), 
				new Emp("smith", 21, 800D, State.BUSY),
				new Emp("张三", 28, 2300D, State.FREE), 
				new Emp("李四", 29, 2450D, State.BUSY), 
				new Emp("王二", 37, 2600D, State.BUSY),
				new Emp("麻子", 40, 2300D, State.VOCATION), 
				new Emp("测试", 30, 2350D, State.BUSY));
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public Double getSal() {
		return sal;
	}

	public void setSal(Double sal) {
		this.sal = sal;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((age == null) ? 0 : age.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((sal == null) ? 0 : sal.hashCode());
		result = prime * result + ((state == null) ? 0 : state.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Emp other = (Emp) obj;
		if (age == null) {
			if (other.age != null)
				return false;
		} else if (!age.equals(other.age))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (sal == null) {
			if (other.sal != null)
				return false;
		} else if (!sal.equals(other.sal))
			return false;
		if (state != other.state)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Emp [name=" + name + ", age=" + age + ", sal=" + sal
				+ ", state=" + state + "]";
	}

//	@Override
//	public int compareTo(Emp o) {
//		double d = this.sal - o.sal;
//		return d == 0 ? 0 : (d > 0 ? 1 : -1);
//	}

}
